<template>
    <el-container class="system-layout">
        <!-- 顶部标题栏 -->
        <el-header class="topbar">
            <div class="text">
                <div class="left">
                    <img class="logo" src="@/assets/logo.png" />
                    <span class="title">灰鲸商城管理系统</span>
                </div>
                <el-input class="global-search" placeholder="全局搜索" prefix-icon="el-icon-search" size="small"
                    style="width:240px;margin-left:20px" />
            </div>
            <!-- 右侧用户操作 -->
            <div class="right">
                <el-dropdown>
                    <span class="user-info">
                        <el-avatar size="small" style="vertical-align: middle;"
                            src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
                        <span class="uname">admin</span>
                        <i class="el-icon-arrow-down"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>个人中心</el-dropdown-item>
                        <el-dropdown-item divided @click.native="logout">
                            退出登录
                        </el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </el-header>

        <el-container class="main-wrapper">
            <!-- 左侧导航 -->
            <el-aside width="220px" class="sidebar">
                <div class="nav-group-title">主导航</div>
                <el-menu :default-active="$route.path" router class="custom-menu" active-text-color="#409EFF"
                    background-color="#fff" text-color="#606266">
                    <el-menu-item index="/system_mall/Dashboard">
                        <i class="el-icon-pie-chart"></i>
                        <span slot="title">仪表盘</span>
                    </el-menu-item>

                    <el-menu-item index="/system_mall/GoodsManage">
                        <i class="el-icon-sugar"></i>
                        <span slot="title">商品管理</span>
                    </el-menu-item>

                    <el-menu-item index="/system_mall/OrderManage">
                        <i class="el-icon-shopping-cart-full"></i>
                        <span slot="title">订单管理</span>
                    </el-menu-item>

                    <el-menu-item index="/system_mall/UserManage">
                        <i class="el-icon-user"></i>
                        <span slot="title">用户管理</span>
                    </el-menu-item>

                    <el-menu-item index="/system_mall/category">
                        <i class="el-icon-menu"></i>
                        <span slot="title">分类管理</span>
                    </el-menu-item>
                </el-menu>
                <div class="nav-group-title">系统设置</div>
                <el-menu router class="custom-menu" active-text-color="#409EFF" background-color="#fff"
                    text-color="#606266">
                    <el-menu-item index="/system_mall/settings">
                       <i class="el-icon-s-tools"></i>
                        <span slot="title">系统设置</span>
                    </el-menu-item>

                    <el-menu-item index="/system_mall/logs">
                        <i class="el-icon-refresh-right"></i>
                        <span slot="title">操作日志</span>
                    </el-menu-item>
                </el-menu>
            </el-aside>

            <!-- 右侧内容 -->
            <el-main class="content">
                <router-view />
            </el-main>
        </el-container>
    </el-container>
</template>
<script>
export default {
    data() {
        return {};
    },
    methods: {
        logout() {
            this.$confirm('确定退出吗?', '提示')
                .then(() => {
                    this.$router.replace('/loginView');
                })
                .catch(() => { });
        }
    }
}
</script>
<style scoped lang="scss">
.system-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    line-height: 60px;
    padding: 0 20px;
    justify-content: space-between;
   border-bottom: 1px solid #e6e6e6;
}

.text {
    display: flex;

    .logo {
        vertical-align: middle;
    }

    .title {
        color: #000;
        font-weight: 700;
        font-size: 26px;
    }
}

.logo {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

/* 主体区域（菜单 + 内容） */
.main-wrapper {
    flex: 1;
    overflow: hidden;
}

.sidebar {
    background: #fff;
    border-right: 1px solid #e6e6e6;
}

.content {
    background: #f5f5f5;
    padding: 20px;
    overflow-y: auto;
}

.nav-group-title {
    color: rgba(107, 114, 128, 1);
    font-size: 12px;
    padding: 0 25px;
    margin: 10px 0;
}

.custom-menu {
  // 原有样式保留
  border: none;
  padding: 0 10px;

  // 菜单选项默认样式
  .el-menu-item {
     margin: 5px 0; 
    font-size: 17px; 
    font-weight: 500;
    color: #606266;  
    height: 40px;   
    line-height: 35px;
  }

  .el-menu-item.is-active {
   background-color: rgb(22 93 255 / 0.1) !important; 
    color: #1890ff !important;            
    font-size: 17px;                    
    border-radius: 4px;
  }

  .el-menu-item:hover {
    color: #1890ff !important;
    background-color: #f0f7ff !important;
     font-size: 17px;      
  }
}
</style>